#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Solution {
public:
	string longestCommonPrefix(vector<string> &strs) {
		if(strs.size()==0)
			return "";
		int i=1;
		string com=commonPrefix(strs[0],strs[0]);
		while(i<strs.size()&&com.length()>0){
			com=commonPrefix(com,strs[i]);
			++i;
		}
		return com;
	}

	string commonPrefix(string &str1,string &str2){
		int i=0;
		string com="";
		while(i<str1.length()&&i<str2.length()){
			if(str1[i]==str2[i])
			{
				com+=str1[i];
				++i;
			}else
				break;
		}
		return com;
	}
};

int main(){
	Solution s;
	vector<string> strs;
	string str;
	while(cin>>str){
		if(str=="x")
			break;
		strs.push_back(str);		
	}
	cout<<s.longestCommonPrefix(strs)<<endl;
}